
//
//  QLWebViewManager.m
//  jSCoreTest
//
//  Created by zhouzhenghua on 16/8/12.
//  Copyright © 2016年 前隆金融. All rights reserved.
//

#import "QLWebViewManager.h"

@interface QLWebViewManager ()
@property (strong, nonatomic) JSContext *context;
@end

@implementation QLWebViewManager
- (BOOL)webView:(UIWebView *)webView shouldStartLoadWithRequest:(NSURLRequest *)request navigationType:(UIWebViewNavigationType)navigationType {
    return YES;
}
- (void)webViewDidStartLoad:(UIWebView *)webView {
    
    if (self.webViewController && [self.webViewController respondsToSelector:@selector(webViewStartLoad:)]) {
        [self.webViewController performSelector:@selector(webViewStartLoad:) withObject:webView];
    }
    
}
- (void)webViewDidFinishLoad:(UIWebView *)webView {
    if (self.webViewController && [self.webViewController respondsToSelector:@selector(webViewFinishLoad:)]) {
        [self.webViewController performSelector:@selector(webViewFinishLoad:) withObject:webView];
    }
    
    self.context = [webView valueForKeyPath:@"documentView.webView.mainFrame.javaScriptContext"];
    
}
- (void)webView:(UIWebView *)webView didFailLoadWithError:(NSError *)error {
    if (self.webViewController && [self.webViewController respondsToSelector:@selector(webView:didFailWithError:)]) {
        [self.webViewController performSelector:@selector(webView:didFailWithError:) withObject:webView withObject:error];
    }
}

@end
